#ifndef LISTITEM_H
#define LISTITEM_H

#include "QObject"
#include "baza/elementpopisa.h"
#include "baza/artikl.h"

class ListItem: public QObject
{
    Q_OBJECT

    Q_PROPERTY(QString name READ itemName NOTIFY dataChanged)
    Q_PROPERTY(int listItemId READ listItemId)
    Q_PROPERTY(float quantity READ quantity WRITE setQuantity NOTIFY dataChanged)
    Q_PROPERTY(bool bought READ isBought WRITE setBought NOTIFY dataChanged)
    Q_PROPERTY(QString unit READ unit WRITE setUnit NOTIFY dataChanged)
    Q_PROPERTY(int itemId READ itemId)
    Q_PROPERTY(int groupId READ groupId)
    Q_PROPERTY(QString groupName READ groupName)
    Q_PROPERTY(bool isAGroup READ isAGroup)
    Q_PROPERTY(int groupNumber READ groupNumber)
    Q_PROPERTY(int index READ index)

public:
    explicit ListItem(QObject *parent = 0);
    ListItem(int id, Artikl item, float quantity, bool bought, QString unit, bool isAGroup, int groupNumber, int index);
    ~ListItem();

    int listItemId(); //id elementa liste
    float quantity();
    bool isBought();
    QString unit();

    int itemId(); //id artikla
    QString itemName(); //ime artikla

    int groupId(); //id grupe kojoj pripada
    QString groupName();

    bool isAGroup();
    int groupNumber();

    int index();

public slots:
    void setBought(bool newBought);
    void setUnit(QString newUnit);
    void setQuantity(float newQuantity);

signals:
    void itemNameChanged(QString newName);
    void dataChanged();

private:
    int m_ListItemId;
    float m_Quantity;
    bool m_Bought;
    QString m_Unit;
    int m_ItemId;
    QString m_ItemName;
    int m_GroupId;
    QString m_GroupName;
    bool m_IsAGroup;
    int m_GroupNumber;
    int m_Index;
};

#endif // LISTITEM_H
